<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var s = new Promise((resolve, reject) => {
            reject()
        }).then(() => {
            console.log(1111)
        }, () => {
            console.log(2222)
        })
        // .then如果传入两个回调函数，则第一个在成功时会执行，第二个再失败时会执行
        //Promise.all([多个promise对象])
        //请求1
        let p1 = new Promise((resolve, reject) => {
            setTimeout(() => {
                console.log(1111)
                resolve(1)
            }, 4000)
        })
        //请求2
        let p2 = new Promise((resolve, reject) => {
            setTimeout(() => {
                console.log(222)
                resolve(2)
            }, 6000)
        })
        //请求3
        let p3 = new Promise((resolve, reject) => {
            setTimeout(() => {
                console.log(333)
                resolve(3)
            }, 3000)
        })
        Promise.all([p1,p2,p3]).then((res)=>{
            console.log(res)
        }).catch((err)=>{
            console.log(err,'失败了')
        })

        function getDe(){
            let o1 = new Promise((resolve, reject) => {
                resolve(100)
            })
            return o1
        }

        async function fn() {
            let x = await getDe()
            console.log(x,'x')
        }
        fn()

    </script>
</body>

</html>